import { request } from "@umijs/max";

// 获取借阅记录列表
export async function getBorrowings(params?: any) {
  return await request('/borrowings/', { params });
}

// 获取借阅记录详情
export async function getBorrowingDetail(id: number) {
  return await request(`/borrowings/${id}/`);
}

// 创建借阅记录
export async function createBorrowing(data: any) {
  return await request('/borrowings/', { method: 'POST', data });
}

// 更新借阅记录
export async function updateBorrowing(id: number, data: any) {
  return await request(`/borrowings/${id}/`, { method: 'PUT', data });
}

// 删除借阅记录
export async function deleteBorrowing(id: number) {
  return await request(`/borrowings/${id}/`, { method: 'delete' });
}

// 续借图书
export async function renewBorrowing(id: number) {
  return await request(`/borrowings/${id}/renew/`, { method: 'POST' });
}

// 获取当前用户的借阅记录
export async function getMyBorrowings(params?: any) {
  return await request('/borrowings/my_borrowings/', { params });
}